# internal
from coin.support.latency.latency_model import LatencyModel

# std
import sys

if len(sys.argv) != 2:
  print('provide argument e.g. 20190807-20190815')
  sys.exit(1)

model = LatencyModel()
model.train_for_dates(sys.argv[1], 'feed_machine')
model.save(path='dump.tmp')

print(model.dummy_cols)

for machine in [
    'feed-01.ap-northeast-1.aws',
    'feed-01.ap-northeast-2.aws',
    'feed-01.cn-hongkong.aliyun',
    'feed-01.eu-west-1.aws'
]:
  print(f"{machine:<8}: {model.predict({'feed_machine': machine})/1e6:.2f} ms")
